﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Antix.Data.Objects
{
    /// <summary>
    /// <para>Defines an index on a DataObject</para>
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
    public class DataIndexAttribute : Attribute
    {
        #region Constructors etc.

        /// <summary>
        /// <para>Create a Index attribute</para>
        /// </summary>
        public DataIndexAttribute(string name, string columns)
        {
            _Name = name;
            _Columns = columns;
            _IsUnique = false;
        }

        #endregion

        #region Properties

        #region Name

        private string _Name = null;

        /// <summary>
        /// <para>Name of the index in the database</para>
        /// </summary>
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        private string _NameOriginal;

        /// <summary>
        /// <para>NameOriginal for this index</para>
        /// </summary>
        public string NameOriginal
        {
            get { return _NameOriginal == null ? _Name : _NameOriginal; }
            set { _NameOriginal = value; }
        }

        #endregion

        #region Columns

        private string _Columns = null;

        /// <summary>
        /// <para>Columns of the index in the database</para>
        /// <para>e.g "Name, DateOfBirth DESC"</para>
        /// </summary>
        public string Columns
        {
            get { return _Columns; }
            set { _Columns = value; }
        }

        #endregion

        #region IsUnique

        private bool _IsUnique;

        /// <summary>
        /// <para>Index is unique</para>
        /// <para>The default is false</para>
        /// </summary>
        public bool IsUnique
        {
            get { return _IsUnique; }
            set { _IsUnique = value; }
        }

        #endregion

        #endregion

        #region Methods

        #endregion
    }
}
